<?php
/**
 * Post dispute form.
 *
 * @category Zend
 * @package Form
 * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc.
 * @version $Id$
 * @link http://framework.zend.com
 * @since Available since release 1.0
 * @license GPL v3
 */

class Application_Form_Response extends Twitter_Form
{
    /**
     * @var int
     */
    protected $_disputeId;
    
    /**
     * 
     * @param type $options
     */
    public function __construct($options = null)
    {
        if (isset($options['disputeId'])) {
            $this->_disputeId = $options['disputeId'];
        }
        
        parent::__construct($options);
    }
    
    /**
     * Setup form elements
     */
    public function init()
    {
        $this->setAttrib('horizontal', true);
        $this->setAttrib('id', 'post');
        
        $this->addElement('text', 'title', array(
            'label' => 'Title',
            'description' => 'A title describing your response.',
            'required' => true,
            'validators' => array(
                array(
                    'validator' => 'NotEmpty',
                    'options' => array(
                        'messages' => array(
                            'isEmpty' => 'Please provide a title for your response.'
                        )
                    )
                )
            )
        ));
        
        $this->addElement('textarea', 'response', array(
            'label' => 'Response',
            'description' => 'Submit a response to this argument.',
            'required' => true,
            'cols' => 1,
            'rows' => 1,
            'validators' => array(
                array(
                    'validator' => 'NotEmpty',
                    'options' => array(
                        'messages' => array(
                            'isEmpty' => 'Enter your response.'
                        )
                    )
                )
            )
        ));
        
        $this->addElement('hidden', 'disputeId', array(
            'required' => true
        ));
        
        $this->addElement('submit', 'respond', array(
            'label' => 'Respond',
            'class' => 'btn btn-success btn-large'
        ));
        
        if ($this->_disputeId) {
            $this->getElement('disputeId')->setValue($this->_disputeId);
        }
    }
    
    /**
     * Set ID for hidden field
     * 
     * @param type $disputeId
     */
    public function setDisputeId($disputeId)
    {
        $this->_disputeId = $disputeId;
    }
}